import allure
from page_base.page_base import Base
from page_element.roncoo_yewu import *
from utils.timer import sleep
import logging


class RoncooYewu(Base):
    """权限管理页面"""
    # 每回改动此处的数字，即可正常添加所有信息
    number = '1'
    # 全局的不能重复的name和number
    all_name = f"止戈权限_角色_{number}"
    all_number = f"44441{number}"

    # 权限管理
    def roncoo_permission(self):
        """登录已经打开过页面-无需使用url"""
        with allure.step("进入权限管理页面"):
            self.click(permission_manage.permission_manage)
        with allure.step("点击添加权限"):
            self.click(permission_pe.permission_add)
        sleep(1)
        with allure.step("输入权限名称"):
            self.send_keys(permission_pe.permission_name, f'{RoncooYewu.all_name}')
        with allure.step("输入权限标识"):
            self.send_keys(permission_pe.permission_sign, f'{RoncooYewu.all_number}')
        with allure.step("输入权限描述"):
            self.send_keys(permission_pe.permission_desk, '描述1止戈')
        with allure.step("点击保存"):
            self.click(permission_pe.permission_save)
        with allure.step("点击确定"):
            self.click(permission_pe.permission_commit)

    # 角色管理
    def roncoo_role(self):
        """接着上面的操作执行"""
        sleep(1)
        with allure.step("进入角色管理页面"):
            self.click(role_pe.role_manage)
        sleep(1)
        with allure.step("点击添加角色"):
            self.click(role_pe.role_add)
        with allure.step("输入角色名称"):
            self.send_keys(role_pe.role_name, f'{RoncooYewu.all_name}')
        with allure.step("输入角色编码"):
            self.send_keys(role_pe.role_code, f'{RoncooYewu.all_number}')
        with allure.step("输入角色描述"):
            self.send_keys(role_pe.role_desk, '角色描述1')
        with allure.step("点击保存"):
            self.click(role_pe.role_save)

    # 操作员管理
    def roncoo_operator(self):
        """接着上面的操作执行"""
        sleep(1)
        with allure.step("进入操作员管理页面"):
            self.click(operator_pe.operator_manage)
        sleep(1)
        with allure.step("点击添加操作员"):
            self.click(operator_pe.operator_add)
        with allure.step("输入操作员姓名"):
            self.send_keys(operator_pe.operator_name, f'{RoncooYewu.all_number}')
        with allure.step("输入操作员登录名"):
            self.send_keys(operator_pe.operator_login_name, f'{RoncooYewu.all_number}@qq.com')
        with allure.step("输入密码"):
            self.send_keys(operator_pe.operator_pwd,'123123')
        with allure.step("输入手机号码"):
            self.send_keys(operator_pe.operator_phone, '13135960767')
        with allure.step("选择状态"):
            self.click(operator_pe.operator_select)
        with allure.step("选择激活"):
            self.click(operator_pe.operator_activation)
        with allure.step("滚动到指定元素"):
            self.scroll_to_element(operator_pe.operator_role)
        with allure.step("输入描述"):
            self.send_keys(operator_pe.operator_desk, "添加操作员的描述")
        with allure.step("选择角色：超级管理员"):
            self.click(operator_pe.operator_role)
        with allure.step("保存"):
            self.click(operator_pe.operator_save)



